$(document).ready(function() {
    initialize()
});

function initialize() {
        carte_resultat()
        }

function carte_resultat() {
            selectedMode = document.getElementById("mode").value;
            latlng_restau = new google.maps.LatLng(barycentre_latitude, barycentre_longitude)
            latlng_invite = new google.maps.LatLng(invite_latitude, invite_longitude)
            options_carte = {
                    zoom: 12,
                    center: latlng_restau,
                    mapTypeId: google.maps.MapTypeId.ROADMAP
                }
            carte_id = document.getElementById("map_canvas")
            map = new google.maps.Map(carte_id, options_carte)
            directionsService = new google.maps.DirectionsService()
            request_direction = {
                    origin: latlng_invite,
                    destination: latlng_restau,
                    travelMode: google.maps.TravelMode[selectedMode],
                    region: 'fr'
                    }
            directionsService = new google.maps.DirectionsService()
            directionsDisplay = new google.maps.DirectionsRenderer()
            directionsService.route(request_direction, function(result, status) 
            {
                            if (status == google.maps.DirectionsStatus.OK) 
                                {
                                directionsDisplay.setDirections(result)
                                }
            })
            directionsDisplay.setMap(map)
            $("#map_direction").html("")
            directionsDisplay.setPanel(document.getElementById("map_direction"))
}
